package homework.level01model03.homework04;

import java.util.ArrayList;
import java.util.Scanner;

public class StudentSelect {
    public static void select(ArrayList<Student> arrayList){
        System.out.println("输入要查找的姓名");
        Scanner scanner = new Scanner(System.in);
        String name = scanner.nextLine();

        int index = -1;
        for (Student student : arrayList) {
            if (name.equals(student.getName())){
                int i = arrayList.indexOf(student);
                break;
            }
        }

        if (index ==-1){
            System.out.println("查找失败");
        }else{
            System.out.println(arrayList.get(index));
            System.out.println("查找成功");
        }

    }
}
